// VBlockBuilder.h
// define VBlockBuilder interface
#ifndef VBLOCKBUILDER_H
#define VBLOCKBUILDER_H

#include "crossbit/common.h"

namespace crossbit {

				class VInst;
				class VBlock;

				class VBlockBuilder {
								public:
												VBlockBuilder();
												virtual ~VBlockBuilder();

												// --------------------------------------------------
												// Interface of VBlockBuilder
												// --------------------------------------------------

												// prepare the construction of a new VBlock
												// "pc" specify the entry address associated with the block
												virtual void getReady(XTMemAddr pc);

												// add new VInstruction "inst" into the block
												virtual void add(VInst *inst);

												// return whether it's the end of the block
												virtual bool isEnd();

												// pack the block and hand it over to caller
												// "pc" specify the entry address of the next instruction following
												virtual VBlock *wrapUp(XTMemAddr pc);


												inline XTRegNum allocVReg() {
																return bb_vreg++;
												}

								protected:
												VBlock *bb_vblock;
												XTUint8 bb_vreg;	    // initialized with 1

				};
}

#endif
